const Koa = require('koa')
const cors = require('koa2-cors'); //解决跨域问题
const router = require('koa-router')() //路由
const bodyParser = require('koa-bodyparser')//对于POST请求的处理
const static = require('koa-static')
const path = require('path')

const app = new Koa()

app.use(bodyParser())
app.use(cors());
app.use(static(path.join(__dirname, 'public')))
// app.use(ctx => {
//     ctx.body = 123
// })



// 引入路由
const user = require('./modules/users.js')
const dept = require('./modules/department')
const token = require('./modules/token')

app.use(token.routes(), token.allowedMethods())
app.use(user.routes(), user.allowedMethods())
app.use(dept.routes(), dept.allowedMethods())

app.listen(3001, () => {
    console.log('服务器已启动成功,侦听3001端口')
})